#include<bits/stdc++.h>
#define ll long long
#define For(i, a, b) for (int i = a; i <= b; i++)
using namespace std;
inline int read(){
    int sum = 0, fh = 1; char ch = getchar();
    while (!isdigit(ch)) {if (ch == '-') fh = -1; ch = getchar();}
    while (isdigit(ch)) {sum = sum * 10 + ch - '0'; ch = getchar();}
    return sum * fh;
}
inline void write(int x){
    if (x == 0){putchar('0'); return ;}stack<char> s;
    if (x < 0) {putchar('-'); x = -x;}
    while(x) {s.push(x % 10 + '0'); x /= 10;}
    while(!s.empty()) {putchar(s.top()); s.pop();}
}
const int MAXN = 1e5 + 10;
int n, m, L, V;
struct node{
    int d, v, a;
} C[MAXN];
int pi[MAXN], pos = 0, cnt = 0, ans1 = 0, ans2;
void turn()
{
    cnt = 0; ans1 = n; pos = pi[m];
    For(i, 1, n)
    {
        if (C[i].d > pi[m])
        {
            ans1--;
            continue;
        }
        if (C[i].a == 0)
        {
            if (C[i].v <= V) ans1--;
            else pos = min(pos, C[i].d);
            continue;
        }
        if (C[i].a > 0)
        {
            if (C[i].v > V) continue;
            double vt = V, v0 = C[i].v, a0 = C[i].a, c = 2.0;
            double dx = (vt * vt - v0 * v0) / (c * a0);
            int pos_i = C[i].d + ceil(dx);
            if (pos_i > pi[m] || C[i].d + dx == pi[m]) ans1--;
            else pos = min(pos, pos_i);
        }
    }
}
void solve()
{
    write(ans1);
    putchar(' ');
    write((ans1 == 0 ? m : (m - 1)));
    putchar('\n');
}
signed main()
{
    freopen("detect.in", "r", stdin);
    freopen("detect.out", "w", stdout);
    int T = read();
    while (T--)
    {
        n = read(); m = read(); L = read(); V = read();
        For(i, 1, n)
        {
            C[i].d = read();
            C[i].v = read();
            C[i].a = read();
        }
        For(i, 1, m)
        {
            pi[i] = read();
        }
        turn();
        solve();
    }
    return 0;
}